package com.xqy.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPool {
    public static void main(String[] args) {

        ExecutorService service = Executors.newFixedThreadPool(5);
        for (int i = 0; i <20 ; i++) {
            service.submit(new Person("小谢"));
            service.submit(new Dog("旺财"));
        }

        service.shutdown();
    }
}

class Person implements Runnable {
    private String name;

    public Person(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+":===>"+name + "在学习");
    }
}
class Dog implements Runnable {
        private String name;

        public Dog(String name) {
            this.name = name;
        }

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName()+":===>"+name + "在吃骨头");
        }
    }